home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 for Intel / NeXTSTEP 3.2 for Intel.iso / NextLibrary / Documentation / Sybase / DBLIB / Section3 / bcp_control.nr < prev    next >
Encoding:
Text File  |  1993-04-22  |  3.0 KB  |  128 lines

  1. .Na "bcp_control"
  2. .mc |
  3. .Aa
  4. .Fu
  5. Change various control parameter default settings.
  6. .Ih "bcp, set control parameters"
  7. .Sy
  8. .Sf "RETCODE bcp_control(dbproc, field, value)"
  9. .Sp "DBPROCESS" "*dbproc"
  10. .Sp "int" "field"
  11. .Sp "DBINT" "value"
  12. .Co
  13. .Bl
  14. This function sets various control parameters for bulk copy
  15. operations, including the number of errors allowed before aborting
  16. a bulk copy, the numbers of the first and last rows to copy, and the
  17. batch size.
  18. .Bl
  19. These control parameters are only meaningful when copying between a host file
  20. and a \*S table.
  21. Control parameter settings have no effect on \f2bcp_bind()\f1 row transfers.
  22. .Bl
  23. The following program fragment illustrates \f2bcp_control()\f1:
  24. .SD
  25. .ta +4n +4n +4n +4n +4n +4n +4n
  26. LOGINREC        *login;
  27. DBPROCESS       *dbproc;
  28. DBINT           rowsread;
  29.  
  30. /* Initialize DB-Library. */
  31. if (dbinit() == FAIL)
  32.     exit(ERREXIT);
  33.  
  34. /* Install error-handler and message-handler. */
  35. dberrhandle(err_handler);
  36. dbmsghandle(msg_handler);
  37.  
  38. /* Open a DBPROCESS. */
  39. login = dblogin();
  40. BCP_SETL(login, TRUE);
  41. dbproc = dbopen(login, NULL);
  42.  
  43. /* Initialize bcp. */
  44. if (bcp_init(dbproc, "comdb..address", "address.add", "addr.error", DB_IN) == FAIL)
  45.     exit(ERREXIT);
  46.  
  47. /* Set the number of rows per batch. */
  48. if (bcp_control(dbproc, BCPBATCH, 1000) == FAIL)
  49. {
  50.     printf("bcp_control failed to set batching behavior.\en");
  51.     exit(ERREXIT);
  52. }
  53.  
  54. /* Set host column count. */
  55. if (bcp_columns(dbproc, 1) == FAIL)
  56. {
  57.     printf("bcp_columns failed.\en");
  58.     exit(ERREXIT);
  59. }
  60.  
  61. /* Set the host-file format. */
  62. if (bcp_colfmt(dbproc, 1, 0, 0, -1, (BYTE *)("\en"), 1, 1) == FAIL)
  63. {
  64.     printf("bcp_colformat failed.\en");
  65.     exit(ERREXIT);
  66. }
  67.  
  68. /* Now, execute the bulk copy. */
  69. if (bcp_exec(dbproc, &rowsread) == FAIL)
  70. {
  71.     printf("Incomplete bulk copy.  Only %ld row%c copied.\en",
  72.             rowsread, (rowsread == 1) ? ' ': 's');
  73.     
  74.     exit(ERREXIT);
  75. }
  76. .ED
  77. .Bl
  78. For information on the \f2bcp\f1 utility program, see its manual page
  79. in the \f2Commands Reference\f1.
  80. .Bz
  81. .Pa
  82. .Pi dbproc
  83. A pointer to the DBPROCESS structure that provides the connection
  84. for a particular front-end/\*S process.  It contains all the
  85. information that \*L uses to manage communications and data between the
  86. front end and \*S.
  87. .Pi field
  88. The \f2field\f1 can be one of the following:
  89. .in +3n
  90. .sp 0.5v
  91. .nf
  92. .ta +1.4i
  93. \f3Field\f1    \f3Description\f1
  94. .sp 0.5v
  95. BCPMAXERRS    The number of errors allowed before giving up.  The
  96.     default is 10.
  97.  
  98. BCPFIRST    The first row to copy. The default is 1.  A value of 
  99.     less than 1 resets this field to its default value of 1.
  100.  
  101. BCPLAST    The last row to copy. The default is to copy all rows. 
  102.     A value less than 1 resets this field to its default value.
  103.  
  104. BCPBATCH    The number of rows per batch. The default is 0, which 
  105.     means that the entire bulk copy will be done in one 
  106.     batch.  This field is only meaningful when copying from 
  107.     a host file into \*S.
  108. .fi
  109. .sp 0.5v
  110. .in -3n
  111. .Pi value 
  112. The value for the specified \f2field\f1.
  113. .in -.375i
  114. .Re
  115. .br
  116. SUCCEED or FAIL.
  117. .Sa
  118. bcp_batch,
  119. bcp_bind,
  120. bcp_colfmt,
  121. bcp_collen,
  122. bcp_colptr,
  123. bcp_columns,
  124. bcp_done,
  125. bcp_exec,
  126. bcp_init
  127. .mc
  128.